package com.topscore.uke.mvp.model;

import com.topscore.uke.entities.StuffListEntity;
import com.topscore.uke.mvp.contractors.GetStuffListContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.request.GetStuffListRequest;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 71468 on 2018/3/14.
 */

public class GetStuffListModel implements GetStuffListContractor, GetStuffListContractor.Model {
    @Override
    public void getStuffList(GetStuffListRequest request, CallBack callBack) {
        mService.getStuffListData(request)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<StuffListEntity>>(callBack) {
                    @Override
                    public void onSuccess(BaseResponse<StuffListEntity> response) {
                        callBack.onGetDataSuccess(response);
                    }
                });
    }
}
